package com.dyh.quickdemozwei.quickSchedule;

import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
public class QuickSchedule {


    long lastSyncTime;


    volatile boolean userOperate;

    class XX{
        int i;
    }

    @Test public void test3(){
        XX xx = new XX();
        xx.i++;

        System.out.println();
    }

    @Test public void test2(){
        List<Long> l1 = Lists.newArrayList(1L,2L,3L);
        List<Long> l2 = Lists.newArrayList(1L,2L,3L);
        List<Long> l3 = Lists.newArrayList(1L,2L,3L,4L);

        l2.removeAll(l1);

        l3.removeAll(l1);

        System.out.println();
    }

    @Test
    public void test() throws InterruptedException {
        Thread t1 = new Thread(()->{
            int i = 0;
            for (;;){

                for (;;){
                    if (!userOperate)
                        break;
                }
                log.info("调度执行开始 {}",i);
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                log.info("调度执行结束 {}",i++);

            }
        });

        Thread t2 = new Thread(()->{
            userOperate = true;
            log.info("用户开始操作");
            try {
                Thread.sleep(200L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            userOperate = false;
            log.info("用户结束操作");

        });

        t1.start();
        Thread.sleep(4000L);
        t2.start();

        t1.join();
    }

    @Test public void test5(){
//        Map<String,String>  m = new HashMap<>();
//        m.put()
    }
}
